<%--
  Created by IntelliJ IDEA.
  User: 陌·笙
  Date: 2018-12-18
  Time: 9:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>库存变动</title>
    <jsp:include page="../comm/tag.jsp"/>
    <script>
       $(function () {
           $("#mytable").bootstrapTable({
               url:"/kucun/showInout",
               height:700,
               pageSize:12,
               pageNumber:1,
               pageList:[4,8,10,12],
               //启用分页，但是默认情况下，是客户端分页的
               pagination:true,
               sidePagination:'server',
               queryParams:function(params){
                   var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                       limit: params.limit,  //页面大小
                       offset: params.offset, //页码
                       repertoryName:$("[name='repertoryName']").val(),
                       typeId:$("[name='typeId']").val(),
                       lasttime:$("[name='lasttime']").val(),
                       times:$("[name='times']").val(),
                   };
                   return temp;
               },
               locale:'zh-CN',//中文支持,
               toolbar:'#top',
               columns:[
                   {field:"repertory.repertoryId",title:"商品编号",align:"center"},
                   {field:"repertory.repertoryName",title:"商品名称",align:"center"},
                   {field:"inoutNum",title:"剩余库存量",align:"center"},
                   {field:"sellNum",title:"销售总数",align:"center"},
                   {field:"lastprice",title:"上次进价",align:"center"},
                   {field:"preinstall",title:"卖价",align:"center"},
                   {field:"theprice",title:"本次进价",align:"center"},
                   {field:"thepricestall",title:"本次卖价",align:"center"},
                   {field:"average",title:"盈利/亏损",align:"center"},
                   {field:"repertory.model",title:"规格型号",align:"center"},
                   {field:"repertory.repertoryColor",title:"颜色",align:"center"}
               ]
           })
           $.ajax({
               url:"/type/showType",
               type:"get",
               success:function(data){
                   $.each(data,function(){
                       var adds=$("<option value='"+this.iptypeid+"'>"+this.iptypeName+"</option>");
                       $(".k").append(adds);
                   });
               }
           })
       });
       function cha(){
           var opts = $("#mytable").bootstrapTable("getOptions") ;
           var repertoryName=$("[name='repertoryName']").val();
           var typeId=$("[name='typeId']").val();
           var lasttime=$("[name='lasttime']").val();
           var times=$("[name='times']").val();
           var limit = opts.pageSize ;
           var offset = (opts.pageNumber-1) * limit;
           $.ajax({
               url:"/kucun/showInout",
               type:"post",
               data:{"repertoryName":repertoryName,"typeId":typeId,"lasttime":lasttime,"times":times,'limit':limit,'offset':offset},
               success:function(data){
                   $("#mytable").bootstrapTable("load",data);
               }
           })
       }
    </script>
</head>
<body>
<div style="margin-left: 50px;margin-right: 50px">
    <div class="#top" style="margin-top: 30px">
        <div class="col-md-1">
            <button onclick="todel()" class="btn btn-primary"><span class="glyphicon glyphicon-save"></span>&nbsp;&nbsp;导出</button>
        </div>

        <div class="col-md-11">
            <form action="" method="post" role="form" class="form-horizontal">
                <div class="form-group col-md-3">
                    <label for="" class="col-md-4 control-label">商品名称:</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control" name="repertoryName" placeholder="可模糊查询">
                    </div>
                </div>
                <div class="form-group col-md-3">
                    <label for="" class="col-md-4 control-label">商品类别:</label>
                    <div class="col-md-8">
                        <select name="typeId" id="inputID" class="form-control k">
                            <option value="0">全部</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="" class="col-md-4 control-label">变动时间:</label>
                    <div class="col-md-8">
                       <div class="col-md-6">
                           <input type="date" class="form-control" name="lasttime">
                       </div>
                        <label for="" class="col-md-1 control-label">至</label>
                        <div class="col-md-5">
                            <input type="date" class="form-control" name="times">
                        </div>
                    </div>
                </div>
                <button type="button" class="btn btn-primary btn-info glyphicon glyphicon-search" onclick="cha()">查询</button>
            </form>
        </div><%--搜索框--%>
    </div>
    <table id="mytable"></table>
</div>
</body>
</html>
